#include "TransformNode.h"


TransformNode::TransformNode(glm::mat4 transform)
{
	this->transf = transform;
	this->children = std::vector<Node*>();
}

TransformNode::~TransformNode(void)
{
	delete( &this->children);
}

void TransformNode::add( Node * newNode){
	children.push_back(newNode);	
}

void TransformNode::rightmultiply(const glm::mat4 & M, std::stack<glm::mat4> &transfstack) {
  glm::mat4 &T = transfstack.top() ; 
  // Right multiply M, but do this left to account for row/column major 
  T = M * T ; 
}

void TransformNode::draw( std::stack<glm::mat4> &transfstack){
	transfstack.push(transf*transfstack.top());
	for (int i=0;i<children.size();i++){
		(children[i])->draw(transfstack);
	}
}